<div id="content">
	<?php

	$is_new = isset($row[0]->userid) ? false : true;
	if($is_new){
		echo form_open('admin/users/add');
	} else {
		echo form_open('admin/users/update');
	}

	$this->load->library('table');
	$tmpl = array( 'table_open' => '<table border="1" class="admin-tableform">' );
	$this->table->set_template($tmpl);
	$table_row = null;
	$table_row[] = 'First Name';
	$table_row[] = form_input('firstname', isset($row[0]->firstname) ? $row[0]->firstname : '' );
	$this->table->add_row($table_row);

	$table_row = null;
	$table_row[] = 'Middle Name';
	$table_row[] = form_input('middle', isset($row[0]->middle) ? $row[0]->middle : '' );
	$this->table->add_row($table_row);

	$table_row = null;
	$table_row[] = 'Last Name';
	$table_row[] = form_input('lastname', isset($row[0]->lastname) ? $row[0]->lastname : '' );
	$this->table->add_row($table_row);

	$table_row = null;
	$table_row[] = 'Username';
	$table_row[] = form_input('username', isset($row[0]->username) ? $row[0]->username : '');
	$this->table->add_row($table_row);

	$table_row = null;
	$table_row[] = 'Email';
	$table_row[] = form_input('email', isset($row[0]->email) ? $row[0]->email : '' );
	$this->table->add_row($table_row);

	$table_row = null;
	$table_row[] = 'Password';
	if($is_new){
		$table_row[] = form_password('password', '', 'id="password"');
		$this->table->add_row($table_row);
		$table_row = null;
		$table_row[] = 'Confirm Password';
		$table_row[] = form_password('cpassword', '', 'id="cpassword"');
		$this->table->add_row($table_row);
	} else {
		$table_row[] = anchor('#','Change Password','id="change-pass"');
		$this->table->add_row($table_row);
	}
	$table_row = null;
	$table_row[] = 'Type';
	//$this->load->helper('Select_helper');
	$table_row[] = type('single', 'type', null, isset($row[0]->type) ? array($row[0]->type) : array('0'));
	$this->table->add_row($table_row);

	$table_row = null;
	$table_row[] = anchor('admin/users','Cancel','class="button"');
	if($is_new){
		$table_row[] = form_submit('','Add','class="button"');
	} else {
		$table_row[] = form_submit('','Update','class="button"');
		echo form_hidden('userid', $row[0]->userid);
	}
	$this->table->add_row($table_row);

	echo $this->table->generate();
	echo form_close();

	?>
</div>